/**
 * 
 */
package neptune.manager.validator;

import neptune.manager.builder.IPAddressRange;
import neptune.manager.model.topology.IPAddress;
import neptune.manager.utils.Logger.MessageType;
import neptune.manager.validator.rules.ipaddress.ControlIpAddressFormatRule;
import neptune.manager.validator.rules.ipaddress.Ip4AddressFormatRule;
import neptune.manager.validator.rules.ipaddress.Ip4SubnetFormatRule;

/**
 * @author Roberto Bifulco [RobertoBifulco.it] [info@robertoBifulco.it]
 * 
 */
public class IpAddressValidator extends Validator<IPAddress> {

	public IpAddressValidator(IPAddressRange controlIpRange) {
		addRule(new Ip4AddressFormatRule());
		addRule(new Ip4SubnetFormatRule());
		addRule(new ControlIpAddressFormatRule(controlIpRange));
	}

	@Override
	public String getName() {
		return "IpAddressValidator";
	}

	@Override
	protected ValidatorResult validationAlgorithm(IPAddress toValidate,
			ValidatorResult result) {

		result.getLog().addMessage(
				"Validating IP address '" + toValidate + "'",
				MessageType.NORMAL);

		return result;
	}

}
